<template>
  <div class="login">
    <van-nav-bar title="注册" left-arrow class="header" @click-left="goback"></van-nav-bar>
    <van-form >
      <van-field v-model="phone" name="用户名"  placeholder="请输入手机号"
        :rules="[{ required: true, message: '请填写手机号' }]"/>
      <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit" @click="goReg(phone)">下一步</van-button>
      </div>
    </van-form>

  </div>
</template>

<script>
export default {
  data(){
    return{
      phone:'',
    }
  },
  methods: {
    goback(){
      this.$router.back()
    },
    goReg(phone){
      this.$service({
        method:'post',
        url:'user/docheckphone',
        data:`tel=${phone}`
      })
      .then(res=>{
       if(res.data.code==200){
          this.$router.push('/regnew?phone='+phone)
       }else if(res.data.code==10005){
        this.$toast('该用户已注册');
       }
      })
    }
  },
 
}
</script scoped>

<style>
    .login{
    padding: 0 .625rem;
  }
  .van-nav-bar{
    margin-bottom: 1.25rem;
  }
.login .van-form .van-field{
  display: inline-block;
  height: 2.75rem;
  margin-bottom: .625rem;
}

#app > div > form > div:nth-child(2) > button{
 border: 0;
  background: linear-gradient(to right, rgb(255, 96, 52), rgb(238, 10, 36));;
}
</style>